//
//  MarioAnimController.cpp
//  HelloWorld
//
//  Created by Marius Ibanez on 27/06/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#include <iostream>
#include "CustomAnimController.h"

#include "InputsManager.h"
#include "CharacterController.h"

#include "SpriteHelperLoader.h"

#include <vector>

MarioAnimController::MarioAnimController(BasicCharacterController* controller):
                                        BasicAnimController(controller)
{
    // graphics
    
	SpriteHelperLoader sh("mario_test.pshs");
    
    
	std::vector<std::string> animFrames;
    
	animFrames.push_back("mario_idle");
	animFrames.push_back("mario_jump");
	animFrames.push_back("mario_sprint_jump");
	animFrames.push_back("mario_air_down");
	animFrames.push_back("mario_break");
    
	//animFrames.push_back("mario_idle");
    animFrames.push_back("mario_walk1");
    animFrames.push_back("mario_walk2");
    
    animFrames.push_back("mario_sprint1");
    animFrames.push_back("mario_sprint2");
    animFrames.push_back("mario_sprint3");
    
    CCAction* animAction;
    
	mImg = sh.animSpriteWithUniqueName(animFrames,
                                         ccp(150,200),
                                         NULL,
                                         0.1f,
                                         0, //number of repeats - if its 0 the animation will run forever or until you stop it
                                         &animAction);
    
    // ANIMATION
    
	animFrames.clear();
    animFrames.push_back("mario_idle");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_IDLE] = animAction;
	animAction->retain();
	
	animFrames.clear();
    animFrames.push_back("mario_jump");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_JUMP] = animAction;
	animAction->retain();
    
	animFrames.clear();
    animFrames.push_back("mario_sprint_jump");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_SPRINT_JUMP] = animAction;
	animAction->retain();
    
	animFrames.clear();
    animFrames.push_back("mario_air_down");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_AIR_DOWN] = animAction;
	animAction->retain();
    
	animFrames.clear();
    animFrames.push_back("mario_break");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_BREAK] = animAction;
	animAction->retain();
    
	animFrames.clear();
    animFrames.push_back("mario_idle");
    animFrames.push_back("mario_walk1");
    animFrames.push_back("mario_walk2");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_WALK] = animAction;
	animAction->retain();
    
	animFrames.clear();
    animFrames.push_back("mario_sprint1");
    animFrames.push_back("mario_sprint2");
    animFrames.push_back("mario_sprint3");
	animAction = sh.actionForFrames( animFrames, 0.1f );
	mAnimList[ANIM_SPRINT] = animAction;
	animAction->retain();
	
	PlayAnim( ANIM_IDLE );
	//mImg->runAction( mAnimList[ANIM_IDLE] );
	//anim_act = ANIM_IDLE;
}